Skip to content

fix: copy modern comments and their authors when extracting slides - #567

Merged
sergey-tihon merged 1 commit into
sergey-tihon:masterfrom
NikiforovAll:fix/slide-modern-comments
Nov 30, 2026
Merged

sergey-tihon merged 1 commit into
sergey-tihon:masterfrom
NikiforovAll:fix/slide-modern-comments

Conversation

@NikiforovAll

Copy link
Copy Markdown
Contributor

Problem

PresentationBuilder copies legacy comments (ppt/comments/comment*.xml) but not modern comments (PowerPoint 2018+ threaded comments).

A slide with a modern comment holds a reference in its extension list:

<p:ext uri="{6950BFC3-D8DA-4A85-94F7-54DA5524770B}">
  <p188:commentRel r:id="rId2"/>
</p:ext>

The builder copies this element with the slide XML, but it does not copy the comment part (ppt/comments/modernComment_*.xml) or the relationship. The output slide then has an r:id that points to a relationship that does not exist. RelationshipValidator reports it:

Part '/ppt/slides/slide1.xml': element 'commentRel' attribute 'id' references
relationship ID 'rId2' which is not registered on this part.

The comment text and the authors are lost.

Fix

  • FluentPresentationBuilder.Copy.cs: CopyRelatedPartsForContentParts now handles p188:commentRel. The new CopyModernCommentPart adds a PowerPointCommentPart to the new slide, copies the comment XML, sets the r:id to the new relationship, and calls PBT.AddRelationships for relationships inside the comment part.
  • CopyModernCommentAuthors copies the authors that the comment part refers to into ppt/authors.xml of the new presentation. It creates the authors part when it is missing and does not add an author two times.
  • PtOpenXmlUtil.cs: new P188 class with the names of the http://schemas.microsoft.com/office/powerpoint/2018/8/main namespace.

Test

  • PB013_SlideWithModernComment extracts the commented slide from the new TestFiles/PB013-ModernComment.pptx and checks that:
    • the output passes Validate (schema and relationships),
    • p188:commentRel points to the copied comment part,
    • the comment id, the comment text and the reply text are kept,
    • the authors part holds the authors of the comment and of the reply.
  • The fixture is a new two-slide deck made in desktop PowerPoint. Slide 2 has one modern comment with one reply, from two authors.
  • Without the fix the test fails with the relationship error above.
  • Full suite: 2597 passed, 2 skipped, 0 failed on net10.0 and on net11.0. dotnet csharpier check . is clean.
  • Desktop PowerPoint opens the output without a repair prompt and shows the comment and the reply.

Notes

  • The comment monikers (pc:sldMk sldId="...") keep the slide id of the source deck. PowerPoint resolves the comment in the output with the old id and with the new id, so this change does not rewrite it.
  • Comment parts made by PowerPoint can hold <p:ext uri="{5BB2D875-25FF-4072-B9AC-8F64D62656EB}"> in the comment extLst. OpenXmlValidator (Microsoft365) reports "The 'uri' attribute is not declared" for this element in the source file too. The copy does not add or change it.
  • Modern comments hold author names, user ids and @mentions. After this change that data goes into the extracted slides, as legacy comment authors already do.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the changes preserving modern PowerPoint comments during slide extraction.

No open issues 🎉

What changed in this PR

This PR updates Clippit’s presentation builder to preserve modern PowerPoint comments when extracting slides, preventing dangling comment relationships and loss of comment text, replies, and author data.

Changes:

  • Copies modern comment parts and updates slide relationships to reference them.
  • Copies referenced authors without duplicate IDs and adds namespace constants for modern comments.
  • Adds a regression test covering output validation, comment relationships, text, replies, and authors.
File Description
Clippit/​PtOpenXmlUtil.cs Adds namespace and element constants for modern PowerPoint comments.
Clippit/​PowerPoint/​Fluent/​FluentPresentationBuilder.Copy.cs Copies modern comment parts, their relationships, and referenced authors.
Clippit.Tests/​PowerPoint/​PresentationBuilderTests.cs Tests preservation of modern comments, replies, authors, and valid relationships during slide extraction.

Review effort: Balanced

@sergey-tihon
sergey-tihon merged commit 6bb4788 into sergey-tihon:master Nov 30, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants